package com.wing.portal.aggregation;

import java.util.Collection;
import java.util.Map;
/**
 * 
 * @author wyf
 * 
 */
public abstract class AbstractFragment implements Fragment {

	private Map<String,String> param;
	private Fragment parent;

	public AbstractFragment(Map<String,String> param, Fragment parent) {
		this.param = param;
		this.parent = parent;
	}

	public AbstractFragment(Map<String,String> param) {
		this.param = param;
	}

	abstract public void addChild(Fragment child);

	abstract public Collection<Fragment> getChildFragments();

	public Map<String,String> getParam() {
		return param;
	}

	public Fragment getParent() {
		return this.parent;
	}

	public String service() {
		try {
			preService();
			return selfService();
		} finally {
			postService();
		}
	}

	public String selfService() {
		return "";
	}

	abstract public void preService();

	abstract public void postService();

}
